package cn.client.data.localData.dao

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import cn.client.data.localData.entity.ChatMsgEntity
import kotlinx.coroutines.flow.Flow


@Dao
interface ChatMsgDao {

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insert(chatMsg: ChatMsgEntity)

    @Query("SELECT * FROM chat_msg WHERE senderId = :senderId AND receiverId = :receiverId ORDER BY id ASC")
    fun getBySenderIdAndReceiverId(senderId: Int, receiverId: Int): Flow<List<ChatMsgEntity>>
}